Google News
logo
JavaScript - Interview Questions
What are the decodeURI() and encodeURI()?
EncodeURI() is used to convert URL into their hex coding. And DecodeURI() is used to convert the encoded URL back to normal.
 
<script>
	var url="my test.php?name=volkswagen&car=polo";

	document.write(encodeURI(url)+ "<br>");

	document.write(decodeURI(url));
</script>
 
Output:
 
my%20test.php?name=volkswagen&car=polo
my test.php?name=volkswagen&car=polo
Advertisement